package com.yanyeori.framework.redis.config;

import com.yanyeori.framework.redis.configprop.RedisConfigProps;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * Config Factory
 *
 * @author chenkuan 2021/1/11
 */
public class ConfigFactory implements InitializingBean {

    private final RedisTemplate<String, Object> redisTemplate;
    private final RedisConfigProps config;

    private static ConfigFactory instance;

    public ConfigFactory(RedisTemplate<String, Object> redisTemplate, RedisConfigProps config) {
        this.redisTemplate = redisTemplate;
        this.config = config;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        instance = this;
    }

    public static RedisTemplate<String, Object> getRedisTemplate() {
        return instance.redisTemplate;
    }

    public static RedisConfigProps getConfig() {
        return instance.config;
    }
}
